package com.tl.juc.c6;

import java.util.concurrent.*;

public class CompletableFutureTest {

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        CompletableFuture<Void> future1 = CompletableFuture.runAsync(() -> System.out.println(1));
        CompletableFuture<Void> future2 = CompletableFuture.runAsync(() -> System.out.println(2));

        CompletableFuture<Integer> allFutures = CompletableFuture.allOf(future1, future2).thenApply(res -> {
            System.out.println(3);
            future1.join() ;
             future2.join();
             return 10;
        });

        System.out.println(allFutures.join());
    }
}
